package top.ahwyy.controller.Action;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import top.ahwyy.controller.impl.userImpl;
import top.ahwyy.controller.inter.user;

public class userRegisterAction implements ServletRequestAware, ServletResponseAware {
	public HttpServletResponse response;
	public HttpServletRequest request;
	public String regiUn;
	public String regiPw;
	public String regiPw2;
	public String regiEm;
	
	public String execute(){
		response.setContentType("text/html;charset=utf-8");
		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		if(regiUn == null || regiPw == null || regiUn.equals("") ||regiPw.equals("") )
			return "false";
		
		
		user ui = new userImpl();
		boolean flag = ui.userRegister(regiUn, regiPw, regiPw2, regiEm);
		
		
		
		if(flag)
			return "success";
		
		return "false";
	}
	
	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		// TODO Auto-generated method stub
		this.response = arg0;

	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request = arg0;
	}

}
